< previous page page_269 next page >

Page 269
The data pointed to by the pszNewPath field, which is at address &H828509FC in this case, showed the following:
B4 A4 94 82 CC 22 85 82 0F 00 00 00 1B 00 00 00
It looks a lot like a NameMapping structure. The first two 32-bit values are &H8294A4B4 and &H828522CC, which could be pointers. The next two 32-bit values are 15 and 27. The name of the source file was 15 characters, which also suggests that this could be a NameMapping structure.
So what facts did I have?
The handle in the hNameMappings field of the SHFILEOPSTRUCT structure is almost certainly a memory pointer. It points to a block of data that contains at least two 32-bit Long values. The second of those values is a pointer to an SHNAMEMAPPING structure.
What is the first value?
I tried copying two files at once, just to see what would happen. The first value in the memory buffer pointed to by the handle promptly changed to 2.
The Mystery Is Solved
The handle can be treated as a pointer to a structure of my own invention that is defined as follows in project FileOp2B.vbp (on the CD that comes with this book), which can also be found in the solution directory for this puzzle:
Private Type SomeSortOfHandle
   mappingcount As Long
   MappingAddress As Long
End Type

The DoACopy function has been rewritten as follows:

' Perform a copy operation
Private Sub DoACopy()
   Dim sh As SHFILEOPSTRUCT
   Dim src$, dest$
   Dim res&
   Dim NameMapping As SHNAMEMAPPING
   Dim MappingInfo As SomeSortOfHandle
   Dim mappingcounter As Long

   Dim OriginalName As String
   Dim FinalName As String

 
< previous page page_269 next page >